/***************************************************************************
 *   Copyright (C) 2008/2009 by Philipp Müller                             *
 *   philipp.mueller@gmx.de                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
 ***************************************************************************/
#ifndef EPGHEADER_H
#define EPGHEADER_H

#include <QWidget>

#include "channellistmodel.h"

class MainWindow;

/**
	@author Philipp Müller <philipp.mueller@gmx.de>
*/
class WidgetEpgHeader : public QWidget
{
    Q_OBJECT

    public:
        WidgetEpgHeader( QWidget *parent = 0 );
        ~WidgetEpgHeader();

        void setMainWindow( MainWindow* mainWindow ) { m_mainWindow = mainWindow; };
        void setModel( ChannelListModel* model ) { m_model = model; };

        QDateTime epgVisibleTime() { return m_epgVisibleTime; };
        void setEpgVisibleTime( QDateTime dateTime );

        QDateTime epgSelectionTime() { return m_epgSelectionTime; };
        void setEpgSelectionTime( QDateTime dateTime ) { m_epgSelectionTime = dateTime; }

        /** Returns the row of the current epg entry list with row in the channel list. Returns -1 in case list is empty */
        int currentEpgItem( int row );

        /** In Epg selects the left schedule of current schedule */
        void selectLeft( int row );

        /** In Epg selects the right schedule of current schedule */
        void selectRight( int row );

        /** stretch factor of epg */
        int stretch() { return m_stretch; };

        /** left space for logo and channel name */
        int logoSpace() { return m_logoSpace; };


    public slots:
        void updateVisibleTime();

        void mousePressEventX( int x );


    private:
        void paintEvent( QPaintEvent * event );

        QDateTime epgMaxVisibleTime();

        MainWindow*       m_mainWindow;
        ChannelListModel* m_model;

        int               m_stretch;
        int               m_logoSpace;
        QDateTime         m_epgSelectionTime;
        QDateTime         m_epgVisibleTime;
};

#endif
